<%@ page import="entity.Teacher812" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="util.PageInfo" %>
<%@ page import="entity.StudentBanTea813" %><%--
  Created by IntelliJ IDEA.
  User: wang'ze'liang
  Date: 2021/8/13
  Time: 20:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/bootstrap-3.4.1-dist/css/bootstrap.css"/>
</head>
<body>
<table class="table table-striped table-hover">
    <tr>
        <td>学生Id</td>
        <td>学生姓名</td>
        <td>学生年龄</td>
        <td>学生性别</td>
        <td>班级名</td>
        <td>授课老师姓名</td>
        <td>删除/修改</td>
    </tr>
    <%
        PageInfo pageInfo = (PageInfo) request.getAttribute("page");
        ArrayList<StudentBanTea813> arrayList = pageInfo.getList();
        for(StudentBanTea813 studentBanTea813 : arrayList) {
    %>
    <tr>
        <td><%=studentBanTea813.getStudentId()%></td>
        <td><%=studentBanTea813.getStudentName()%></td>
        <td><%=studentBanTea813.getStudentAge()%></td>
        <td><%=studentBanTea813.getStudentGender()%></td>
        <td><%=studentBanTea813.getBanJiName()%></td>
        <td><%=studentBanTea813.getTeacherName()%></td>
        <td>
            <a class="btn btn-warning btn-sm" href="javascript:void(0)" onclick="deleteById(<%=studentBanTea813.getStudentId()%>)">删除</a>
            <a class="btn btn-success btn-sm" href="<%=request.getContextPath()%>/student813?method=selectById&id=<%=studentBanTea813.getStudentId()%>" >修改</a>

        </td>
    </tr>
    <%
        }
    %>
</table>
<a class="btn btn-success" href="<%=request.getContextPath()%>/teacher812?te=selectAll">添加</a>

<nav aria-label="Page navigation">
    <ul class="pagination pagination-lg">
        <li  ><a href="<%=request.getContextPath()%>/student813?method=selectByPage&pageNo=1" aria-label="Previous"><span aria-hidden="true">首页</span></a></li>

        <%
            if(pageInfo.getPageNo() > 1){
        %>
        <li ><a href="<%=request.getContextPath()%>/student813?method=selectByPage&pageNo=<%=pageInfo.getPageNo()-1%>" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
        <%
            } else {
        %>
        <li class="disabled"><a aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
        <%
            }
        %>
        <%
            for (int i = 1; i <= pageInfo.getTotalPage();i++){
        %>
        <li class="<%
        if (pageInfo.getPageNo() == i){
        %>active<%
        }
        %>"><a href="<%=request.getContextPath()%>/student813?method=selectByPage&pageNo=<%=i%>"><%=i%> <span class="sr-only">(current)</span></a></li>
        <%
            }
        %>
        <%
            if (pageInfo.getPageNo() < pageInfo.getTotalPage()) {
        %>
        <li ><a href="<%=request.getContextPath()%>/student813?method=selectByPage&pageNo=<%=pageInfo.getPageNo()+1%>" aria-label="Next"><span aria-hidden="true">&raquo;</span></a></li>
        <%
            } else {
        %>
        <li class="disabled"><a aria-label="Next"><span aria-hidden="true">&raquo;</span></a></li>
        <%
            }
        %>
        <li ><a href="<%=request.getContextPath()%>/student813?method=selectByPage&pageNo=<%=pageInfo.getTotalPage()%>" aria-label="Next"><span aria-hidden="true">尾页</span></a></li>
        <li>
            <span >到第<input type="text" id="num1" >页</span>
        </li>
        <li>
            <a class="btn btn-default" href="javascript:void(0)" onclick="getNum()">跳转</a>
        </li>
    </ul>
</nav>

<script type="text/javascript">
    function getNum(){
        var num = document.getElementById("num1").value;
        location.href = "<%=request.getContextPath()%>/student813?method=selectByPage&pageNo=" + num;
    }
    function deleteById(id){
        var isDelete = confirm("确认删除");
        if (isDelete) {
            location.href = "<%=request.getContextPath()%>/student813?method=deleteById&id=" + id;
        }
    }
</script>

</body>
</html>
